package com.siboxuetang.need.vo;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class LogEntity {

    //访问客户端ip
    private String ip;

    //操作用户id
    private String userId = "nobody";

    //响应时间
    private long responseTime;

    //调用api及其参数
    private String api;

    //返回状态码
    private String status = "200";

    //错误
    private String error = "无";

    //消息
    private String msg = "无";

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getApi() {
        return api;
    }

    public void setApi(String api) {
        this.api = api;
    }

    public long getResponseTime() {
        return responseTime;
    }

    public void setResponseTime(long responseTime) {
        this.responseTime = responseTime;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public void record(Class<?> classClass) {
        Logger logger = LogManager.getLogger(classClass);
        logger.info(ip + "\tuser:" + userId + "\tapi:" + api + "\tresponseTime:" + responseTime);
    }
}
